package classes
{
	import classes.view.Mediator_Main;
	import classes.view.component.Main;

	import flash.display.Stage;

	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class RootMediator extends Mediator implements IMediator
	{
		public static const NAME:String = "RootMediator";
		
		public function RootMediator(mediatorName:String=null, viewComponent:Object=null)
		{
			super(mediatorName, viewComponent);
		}

		override public function listNotificationInterests():Array
		{
			return [
				OX_Application.INITIALIZE_SITE
			];
		}

		override public function handleNotification(notification:INotification):void
		{
			switch(notification.getName()){
				case OX_Application.INITIALIZE_SITE :
					initMain();
				break;
			}
		}
		
		private function initMain():void
		{
			facade.removeMediator( RootMediator.NAME );

			var main:Main = new Main();
			facade.registerMediator( new Mediator_Main( Mediator_Main.NAME, main ));

			stage.addChild(main);

		}

		protected function get stage():Stage
		{
			return viewComponent as Stage;
		}

	}
}